import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  { title: '资方名称', dataIndex: 'name', align: 'left', width: 200 },
  { title: '编号', dataIndex: 'code', width: 50 },
  { title: '产品名称', dataIndex: 'description', align: 'left', slots: { customRender: 'description' } },
  { title: '排序', dataIndex: 'sort', width: 100 },
  { title: '操作人', dataIndex: 'updateName', width: 100 },
  { title: '操作时间', dataIndex: 'updateTime', width: 150 },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  { label: '资方名称', field: 'name', component: 'Input', componentProps: { placeholder: '', autoComplete: 'off', }, },
  { label: '排序', field: 'sort', component: 'Input', componentProps: { placeholder: '', autoComplete: 'off', }, }
];

// ------------------------------------------------------------------------------
export const ItemColumns: BasicColumn[] = [
  { title: '字典id', dataIndex: 'dictId', ifShow: false, },
  { title: '产品名称', dataIndex: 'itemText', align: 'left', width: 100, },
  { title: '编号', dataIndex: 'itemValue', width: 50 },
  { title: '客户等级', dataIndex: 'description', align: 'left', width:120, slots: { customRender: 'customerLevel' } },
  { title: '排序', dataIndex: 'sortOrder', width: 45, },
  { title: '状态', dataIndex: 'status', width: 45, 
    customRender: ({ text }) => {
      return render.renderDict(text, 'dict_item_status')
    }
  },
];

export const searchItemFormSchema: FormSchema[] = [
  {
    label: '字典id',
    field: 'dictId',
    component: 'Input',
  },
  {
    label: '字典项文本',
    field: 'itemText',
    component: 'Input',
  },
];

export const itemFormSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  { label: '产品名称', field: 'itemText', component: 'Input', componentProps: { placeholder: '', autoComplete: 'off', }, },
  { label: '排序', field: 'sortOrder', component: 'InputNumber', },
  { label: '状态', field: 'status', defaultValue: 1, component: 'JDictSelectTag',
    componentProps: {
      type: 'radioButton',
      dictCode: 'dict_item_status',
      stringToNumber: true,
    },
  },
];

//客户等级 ===================================================
export const LevelColumns: BasicColumn[] = [
  { title: '字典id', dataIndex: 'dictId', ifShow: false, },
  { title: '等级', dataIndex: 'itemText', align: 'left', width: 100, },
  { title: '编号', dataIndex: 'itemValue', width: 45, },
  { title: '排序', dataIndex: 'sortOrder', width: 45, },
  { title: '状态', dataIndex: 'status', width: 45, customRender: ({ text }) => render.renderDict(text, 'dict_item_status') },
];

export const levelFormSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  { label: '等级', field: 'itemText', component: 'Input', componentProps: { placeholder: '', autoComplete: 'off', }, },
  { label: '排序', field: 'sortOrder', component: 'InputNumber', componentProps: { placeholder: '', autoComplete: 'off', }, },
  { label: '状态', field: 'status', defaultValue: 1, component: 'JDictSelectTag',
    componentProps: {
      type: 'radioButton',
      dictCode: 'dict_item_status',
      stringToNumber: true,
    },
  },
];